package com.atguigu.tingshu.album.rpc;

import com.atguigu.tingshu.album.service.AlbumInfoService;
import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.album.service.TrackInfoService;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.album.AlbumInfo;
import com.atguigu.tingshu.model.album.BaseCategory3;
import com.atguigu.tingshu.model.album.BaseCategoryView;
import com.atguigu.tingshu.model.album.TrackInfo;
import com.atguigu.tingshu.vo.album.AlbumStatVo;
import com.atguigu.tingshu.vo.album.TrackListVo;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author：yyj
 * @Package：com.atguigu.tingshu.album.rpc
 * @Project：tingshu_parent240829
 * @name：AlbumInfoRpcController
 * @Date：2025/1/19 22:29
 * @Filename：AlbumInfoRpcController
 */
@RestController
@RequestMapping("api/inner/albumInfo")
public class AlbumInfoRpcController {
    @Autowired
    private AlbumInfoService albumInfoService;
    @Autowired
    private BaseCategoryService baseCategoryService;
    @Autowired
    private TrackInfoService trackInfoService;

    @GetMapping("/getAlbumInfo/{albumId}")
    @Operation(summary = "根据专辑id获取专辑基本信息的标签信息")
    Result<AlbumInfo> getAlbumInfo(@PathVariable(value = "albumId") Long albumId) {
        AlbumInfo albumInfo = albumInfoService.getAlbumInfo(albumId);
        return Result.ok(albumInfo);
    }

    @GetMapping("/getAlbumInfoCategory/{albumId}")
    @Operation(summary = "根据专辑id获取专辑分类信息")
    Result<BaseCategoryView> getAlbumInfoCategory(@PathVariable(value = "albumId") Long albumId) {
        BaseCategoryView baseCategoryView = baseCategoryService.getAlbumInfoCategory(albumId);
        return Result.ok(baseCategoryView);

    }

    @GetMapping("/getAlbumInfoStat/{albumId}")
    @Operation(summary = "远程调用查询微服务专辑的状态信息")
    Result<AlbumStatVo> getAlbumInfoStat(@PathVariable(value = "albumId") Long albumId) {
        AlbumStatVo albumStatVo = albumInfoService.getAlbumInfoStat(albumId);
        return Result.ok(albumStatVo);
    }


    @GetMapping("/getC1Id7TopBaseCategory3List/{c1Id}")
    @Operation(summary = "根据一级分类id 查询该一级分类下自定的7个三级分类")
    Result<List<BaseCategory3>> getC1Id7TopBaseCategory3List(@PathVariable(value = "c1Id") Long c1Id) {
        List<BaseCategory3> baseCategory3List = baseCategoryService.getC1Id7TopBaseCategory3List(c1Id);
        return Result.ok(baseCategory3List);
    }

    @GetMapping("/getCategory1IdList")
    @Operation(summary = "获取所有一级分类id集合")
    Result<List<Long>> getCategory1IdList() {
        List<Long> c1IdList = baseCategoryService.getCategory1IdList();
        return Result.ok(c1IdList);
    }

    @PostMapping("/getTrackInfoList")
    @Operation(summary = "获取收藏的声音集合")
    Result<List<TrackListVo>> getTrackInfoList(@RequestBody List<Long> collectTrackIds) {
        List<TrackListVo> trackInfoVoList = albumInfoService.getTrackInfoList(collectTrackIds);
        return Result.ok(trackInfoVoList);
    }

    @GetMapping("/getTrackInfoById/{trackId}")
    @Operation(summary = "根据声音id查询声音对象")
    Result<TrackInfo> getTrackInfoById(@PathVariable(value = "trackId") Long trackId) {
        TrackInfo byId = trackInfoService.getById(trackId);
        return Result.ok(byId);
    }

    @GetMapping("/getPaidTrackAndFilterCanPayTrack/{userId}/{albumId}/{trackCount}/{trackId}")
    @Operation(summary = "既能把买过的声音查询出来又能把买过的声音过滤掉 返回真正能买的声音")
    Result<List> getPaidTrackAndFilterCanPayTrack(@PathVariable(value = "userId") Long userId,
                                                  @PathVariable(value = "albumId") Long albumId,
                                                  @PathVariable(value = "trackCount") Integer trackCount,
                                                  @PathVariable(value = "trackId") Long trackId) {
        return trackInfoService.getPaidTrackAndFilterCanPayTrack(userId, albumId, trackCount, trackId);
    }


    @GetMapping("/getAlbumIds")
    @Operation(summary = "获取专辑所有id")
    Result<List<Long>> getAlbumIds() {
        List<Long> getAlbumIds= albumInfoService.getAlbumIds();
        return Result.ok(getAlbumIds);
    }
}